<template>
  <ElCard :header="$t('page.home.systemInfo.title')" :body-style="{ padding: '8px 24px' }">
    <div class="info-row">
      <span class="label">IP：</span>
      <span class="value">{{ systemInfo.wanIp }}</span>
    </div>
    <div class="info-row">
      <span class="label">局域网IP：</span>
      <span class="value">{{ systemInfo.lanIp }}</span>
    </div>
    <div class="info-row">
      <span class="label">主机名称：</span>
      <span class="value">{{ systemInfo.hostName }}</span>
    </div>
    <div class="info-row">
      <span class="label">系统名称：</span>
      <span class="value">{{ systemInfo.systemOs }}</span>
    </div>
    <div class="info-row">
      <span class="label">系统架构：</span>
      <span class="value">{{ systemInfo.osArchitecture }}</span>
    </div>
    <div class="info-row">
      <span class="label">CPU核心数：</span>
      <span class="value">{{ systemInfo.processorCount }}</span>
    </div>

    <div class="info-row">
      <span class="label">内存占用：</span>
      <span class="value">{{ systemInfo.ramUse }}</span>
    </div>


    <div class="info-row">
      <span class="label">框架版本：</span>
      <span class="value">{{ systemInfo.frameworkDescription }}</span>
    </div>
    <div class="info-row">
      <span class="label">运行时间：</span>
      <span class="value">{{ systemInfo.runTime }}</span>
    </div>
  </ElCard>
</template>

<script setup lang="ts">
import { MachineInfo } from '@/api-services';
import { SystemserviceApi } from '@/api-services/apis/systemservice-api';
import { feature, getAPI } from '@/axios-utils';
import { queryDone } from '@/utils/api';
import { onMounted, ref } from 'vue';
const systemInfo = ref<MachineInfo>({});

const getSystemInfo = async () => {
  const [err, res] = await feature(getAPI(SystemserviceApi).getSystemInfo());
  queryDone(err, () => {
    if (res?.data.data) {
      systemInfo.value = res?.data.data;
    }
  });
};

onMounted(() => {
  getSystemInfo();
});
</script>

<style scoped>
.container {
  padding: 24px;
  max-width: 800px;
  margin: 0 auto;
}

.info-card {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.info-row {
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
}

.info-row:last-child {
  border-bottom: none;
}

.label {
  font-weight: 500;
  color: rgba(0, 0, 0, 0.85);
  min-width: 120px;
  display: inline-block;
}

.value {
  color: rgba(0, 0, 0, 0.65);
}
</style>
